<admintpl file="header" />
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('Machine/index')}">设备列表</a></li>
            <li class="active"><a>修改设备</a></li>
        </ul>
        <form action="{:U('Machine/edit_post')}" method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data">
            <div class="row-fluid">
                <div class="span12">
                	<if condition="$machine['error']" >{$machine.error}</if>
                    <table class="table table-bordered" style="margin-bottom: -1px;">
                    	<tr>
                            <th>终端ID</th>
                            <td>
                                <input type="text" name="tmlid" readonly="readonly" value="{$machine.tmlid}"/>
                            </td>
                            <th>终端SN</th>
                            <td >
                                <input type="text" readonly="readonly" value="{$machine.tmlsn}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>终端名称</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.name}"/>
                            </td>
                            <th>软件版本</th>
                            <td>
                                <input type="text"  readonly="readonly" value="{$machine.version}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>IP地址</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.tmlipaddress}"/>
                            </td>
                            <th>MAC地址</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.tmlmicaddress}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>设备容量</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.tmldisk}"/>
                            </td>
                            <th>终端状态</th>
                            <td>
                                <input type="text" readonly="readonly" <if condition="$machine['online']" > value="在线" <else /> value="离线"</if> />
                            </td>
                        </tr>
                         <tr>
                            <th>店铺名称</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$store.title}"/>
                            </td>
                            <th>子名称</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$store.title_branch}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>店铺地址</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$store.address}"/>
                            </td>
                            <th>坐标</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$store.longitude},{$store.latitude}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>接入时间</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.tmltime}"/>
                            </td>
                            <th>最后更新</th>
                            <td>
                                <input type="text" readonly="readonly" value="{$machine.updated_at}"/>
                            </td>
                        </tr>
                        <tr>
                            <th>当前亮度</th>
                            <td>
				            <select name="bright" style="width: 222px;">
								<for start="0" end="101" step="5">
				                    <option value="{$i}" <if condition="$i eq $bright" >selected </if>>{$i}%</option>
								</for>
				            </select>
                            </td>
                            <th>开关机时间</th>
                            <td>
                                <foreach name="tmlsns" item="vo" key="k">
		                        <div style="margin: 10px 5px;">
						            <select name="startuph[{$k}]" style="width: 69px;">
										<for start="0" end="24">
						                    <option value="{$i}"<if condition="$i eq substr($vo['startTime'],0,2)" >selected </if>>{$i}时</option>
										</for>
						            </select>
						            <select name="startupi[{$k}]" style="width: 69px;">
										<for start="0" end="60">
						                    <option value="{$i}"<if condition="$i eq substr($vo['startTime'],3,2)" >selected </if>>{$i}分</option>
										</for>
						            </select>
		                             ~
						            <select name="shutdownh[{$k}]" style="width: 69px;">
										<for start="0" end="24">
						                    <option value="{$i}"<if condition="$i eq substr($vo['endTime'],0,2)" >selected </if>>{$i}时</option>
										</for>
						            </select>
						            <select name="shutdowni[{$k}]" style="width: 69px;">
										<for start="0" end="60">
						                    <option value="{$i}"<if condition="$i eq substr($vo['endTime'],3,2)" >selected </if>>{$i}分</option>
										</for>
						            </select>
						            <select name="sound[{$k}]" style="width: 122px;">
										<for start="0" end="101" step="5">
						                    <option value="{$i}" <if condition="$i eq $vo['volume']" >selected </if>>音量：{$i}%</option>
										</for>
						            </select>
						            <a href="javascript:void(0);" onclick="delDesktop(this);" class="btn">删除</a>
		                        </div>
                               </foreach>
		                        <div>
	                    		<a href="javascript:void(0);" onclick="addNewDesktop(this,{$k});" class="btn btn-primary">添加时段</a>
		                        </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="form-actions">
	        		<button class="btn btn-primary js-ajax-submit" type="submit" data-action="{:U('Machine/shutdown')}">关机</button>
	        		<button class="btn btn-primary js-ajax-submit" type="submit" data-action="{:U('Machine/startup')}">开机</button>
                <button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
                <a class="btn" href="{:U('Machine/index')}">返回</a>
            </div>
        </form>

    </div>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>

	<script type="text/javascript">
		var j=0;
        function delDesktop(dom){
            $(dom.parentNode).remove();
        }
        function addNewDesktop(dom,i){
        	i = ++j +i;
            var par = $(dom.parentNode);
            var temp ='<div style="margin: 10px 5px;">\
		            <select name="startuph['+i+']" style="width: 69px;"><for start="0" end="24"><option value="{$i}">{$i}时</option></for></select>\
		            <select name="startupi['+i+']" style="width: 69px;"><for start="0" end="60"><option value="{$i}">{$i}分</option></for></select> ~ \
		            <select name="shutdownh['+i+']" style="width: 69px;"><for start="0" end="24"><option value="{$i}">{$i}时</option></for></select>\
		            <select name="shutdowni['+i+']" style="width: 69px;"><for start="0" end="60"><option value="{$i}">{$i}分</option></for></select>\
		            <select name="sound['+i+']" style="width: 122px;"><for start="0" end="101" step="5"><option value="{$i}">音量：{$i}%</option></for></select>\
                	<a href="javascript:void(0);" onclick="delDesktop(this);" class="btn">删除</a>\
                    </div>';
            par.before(temp);
        }
	</script>
</body>
</html>
